]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspacesView: Fix PgUp/PgDown shortcut
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 8 Apr 2021 15:19:37 +0000 (17:19 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 8 Apr 2021 18:48:58 +0000 (20:48 +0200)
We still try to switch to the workspace above/below, which doesn't
do anything since the layout is now horizontal.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1798>

js/ui/workspacesView.js

index 1af45d88d7d5f0f368b9d2da0d24c9cffb7e30ea..2c9da5c9bba961504d8cab9ef964c44c31a6ad86 100644 (file)
@@ -1144,20 +1144,36 @@ class WorkspacesDisplay extends St.Widget {
     _onKeyPressEvent(actor, event) {
         if (!this.mapped)
             return Clutter.EVENT_PROPAGATE;
-        let workspaceManager = global.workspace_manager;
-        let activeWs = workspaceManager.get_active_workspace();
-        let ws;
+
+        const { workspaceManager } = global;
+        const vertical = workspaceManager.layout_rows === -1;
+        const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
+
+        let dir;
         switch (event.get_key_symbol()) {
         case Clutter.KEY_Page_Up:
-            ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
+            if (vertical)
+                dir = Meta.MotionDirection.UP;
+            else if (rtl)
+                dir = Meta.MotionDirection.RIGHT;
+            else
+                dir = Meta.MotionDirection.LEFT;
             break;
         case Clutter.KEY_Page_Down:
-            ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN);
+            if (vertical)
+                dir = Meta.MotionDirection.DOWN;
+            else if (rtl)
+                dir = Meta.MotionDirection.LEFT;
+            else
+                dir = Meta.MotionDirection.RIGHT;
             break;
         default:
             return Clutter.EVENT_PROPAGATE;
         }
-        Main.wm.actionMoveWorkspace(ws);
+
+        const ws = workspaceManager.get_active_workspace().get_neighbor(dir);
+        if (ws)
+            Main.wm.actionMoveWorkspace(ws);
         return Clutter.EVENT_STOP;
     }